import { createStore, createLogger } from 'vuex'

export interface RootState {
  user: {
    isLogin: boolean
    nickname: string
    token: string
  }
}

export default createStore<RootState>({
  state: {
    user: {
      isLogin: false,
      nickname: '',
      token: localStorage.getItem('token') || ''
    }
  },
  mutations: {
    SET_USER(state, payload) {
      state.user = Object.assign({}, state.user, payload)
    }
  },
  actions: {
  },
  plugins: [createLogger()]
})
